﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using pcceftaw.Models;
using pcceftaw.MembershipRoleProvider;

namespace pcceftaw.Controllers
{
    [Authorize]
    [Filtro(Roles = "Especialista")]
    public class TipoRecursoSwController : Controller
    {
        private DBContainer db = new DBContainer();

        //
        // GET: /TipoRecursoSw/

        public ViewResult Index()
        {
            return View(db.ret_tb_tipoRecursoSw.ToList());
        }

        //
        // GET: /TipoRecursoSw/Details/5

        public ViewResult Details(int id)
        {
            ret_tb_tipoRecursoSw ret_tb_tiporecursosw = db.ret_tb_tipoRecursoSw.Single(r => r.id_tipoRecursoSw == id);
            return View(ret_tb_tiporecursosw);
        }

        //
        // GET: /TipoRecursoSw/Create

        public ActionResult Create()
        {
            return View();
        } 

        //
        // POST: /TipoRecursoSw/Create

        [HttpPost]
        public ActionResult Create(ret_tb_tipoRecursoSw ret_tb_tiporecursosw)
        {
            if (ModelState.IsValid)
            {
                db.ret_tb_tipoRecursoSw.AddObject(ret_tb_tiporecursosw);
                db.SaveChanges();
                return RedirectToAction("Index");  
            }

            return View(ret_tb_tiporecursosw);
        }
        
        //
        // GET: /TipoRecursoSw/Edit/5
 
        public ActionResult Edit(int id)
        {
            ret_tb_tipoRecursoSw ret_tb_tiporecursosw = db.ret_tb_tipoRecursoSw.Single(r => r.id_tipoRecursoSw == id);
            return View(ret_tb_tiporecursosw);
        }

        //
        // POST: /TipoRecursoSw/Edit/5

        [HttpPost]
        public ActionResult Edit(ret_tb_tipoRecursoSw ret_tb_tiporecursosw)
        {
            if (ModelState.IsValid)
            {
                db.ret_tb_tipoRecursoSw.Attach(ret_tb_tiporecursosw);
                db.ObjectStateManager.ChangeObjectState(ret_tb_tiporecursosw, EntityState.Modified);
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            return View(ret_tb_tiporecursosw);
        }

        //
        // GET: /TipoRecursoSw/Delete/5
 
        public ActionResult Delete(int id)
        {
            ret_tb_tipoRecursoSw ret_tb_tiporecursosw = db.ret_tb_tipoRecursoSw.Single(r => r.id_tipoRecursoSw == id);
            return View(ret_tb_tiporecursosw);
        }

        //
        // POST: /TipoRecursoSw/Delete/5

        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(int id)
        {            
            ret_tb_tipoRecursoSw ret_tb_tiporecursosw = db.ret_tb_tipoRecursoSw.Single(r => r.id_tipoRecursoSw == id);
            db.ret_tb_tipoRecursoSw.DeleteObject(ret_tb_tiporecursosw);
            db.SaveChanges();
            return RedirectToAction("Index");
        }

        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }
    }
}